package com.zjj.config;


import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.support.AbstractDispatcherServletInitializer;

public class ServletContainersInitConfig extends AbstractDispatcherServletInitializer {
    @Override
    protected WebApplicationContext createServletApplicationContext() {

        //加载springMVC配置类
        AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
        //加载指定配置类
        ctx.register(SpringMVCConfig.class);

        return ctx;
    }

    //设定springMVC对应的请求映射路径 即springMVC拦截哪些请求
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    //加载spring环境
    @Override
    protected WebApplicationContext createRootApplicationContext() {
        return null;
    }
}
